﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

namespace LabMS.Web.LabEvaluation
{
    public partial class PreViewStandard : Base.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            strPagePrivilege.Add("ZDPGBZ");
            strPageUserType.Add("mana");
            if (Request.QueryString["ID"] != null)
            {
                if (!IsPostBack)
                {
                    int ID;
                    if (int.TryParse(Request.QueryString["ID"].ToString(), out ID))
                    {
                        LabMS.BLL.Standard sta = new LabMS.BLL.Standard();
                        LabMS.Model.Standard staModel = new LabMS.Model.Standard();

                        staModel = sta.GetModel(ID);
                        IDHF.Value = ID.ToString();
                        BindData(ID);
                    }
                    else
                    {
                        ERRLbl.Text = "系统异常，参数不合法！";
                        ERRLbl.Visible = true;
                        modifybtn.Visible = false;
                    }
                }
            }
            else
            {
                ERRLbl.Text = "系统异常，参数不合法！";
                ERRLbl.Visible = true;
                modifybtn.Visible = false;
            }
        }

        //绑定数据
        protected void BindData(int ID)
        {
            LabMS.BLL.Standard sta = new LabMS.BLL.Standard();
            LabMS.Model.Standard staModel = new LabMS.Model.Standard();

            staModel = sta.GetModel(ID);
            CodeLbl.Text = staModel.St_Num.ToString();
            ContentLbl.Text = staModel.St_Content;
            StandardLbl.Text = staModel.St_Standard.Replace("\r\n","<br/>");
            MethodLbl.Text = staModel.St_Method.Replace("\r\n", "<br/>");
            ExplainLbl.Text = staModel.St_Explain.Replace("\r\n", "<br/>");
        }

        //删除
        protected void Delete_OnClick(object sender, EventArgs e)
        {
            ExtendBLL.LabEvaluation labEva = new ExtendBLL.LabEvaluation();

            string ID = IDHF.Value;
            List<string> strID = new List<string>();
            List<string> strTable = new List<string>();
            List<string> strColName = new List<string>();
            #region 评估标准
            strID.Add(ID);
            strTable.Add("Standard");
            strColName.Add("ID");
            #endregion
            #region 自评结果
            strID.Add(ID);
            strTable.Add("Evaluation");
            strColName.Add("StandarID");
            #endregion
            try
            {
                labEva.DeleteStandard(strID, strTable, strColName);
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('删除成功!');refreshParent();wincolse();</script>");
            }
            catch
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('删除失败!');refreshParent();wincolse();</script>");
                return;
            }
        }
    }
}
